From 632780ebef1044ee110d5cbcdd850d72a92ed55f Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sat, 30 May 2015 08:48:25 -0400 Subject: [PATCH] Fix the detection of directories when listing files using libgit2 --- Cargo.lock | 1 + Cargo.toml | 1 + src/cargo/lib.rs | 1 + src/cargo/sources/path.rs | 5 ++--- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f567d62b3..7639e26d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,7 @@ dependencies = [ "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)", "kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 7549de414..c9323fb8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ git2 = { version = "0.2", features = ["unstable"] } git2-curl = "0.2" glob = "0.2" libc = "0.1" +libgit2-sys = "0.2" log = "0.3" num_cpus = "0.1" regex = "0.1" diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 3a47f1eac..e9c98355b 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -10,6 +10,7 @@ extern crate flate2; extern crate git2; extern crate glob; extern crate libc; +extern crate libgit2_sys; extern crate num_cpus; extern crate regex; extern crate registry; diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index f9f33b8ec..d1f6f97fa 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -6,7 +6,6 @@ use std::path::{Path, PathBuf}; use git2; use glob::Pattern; -use libc; use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry}; use ops; @@ -147,8 +146,8 @@ impl<'cfg> PathSource<'cfg> { // the untracked files are often part of a build and may become relevant // as part of a future commit. let index_files = index.iter().map(|entry| { - let is_dir = entry.mode & (libc::S_IFMT as u32) == - (libc::S_IFDIR as u32); + use libgit2_sys::git_filemode_t::GIT_FILEMODE_COMMIT; + let is_dir = entry.mode == GIT_FILEMODE_COMMIT as u32; (join(&root, &entry.path), Some(is_dir)) }); let mut opts = git2::StatusOptions::new(); -- 2.30.2